import java.util.ArrayList;

import Units.Unit;
import framework.info.gridworld.grid.Location;


public class DEFINATELY_NOT_PORN {
	
	public ArrayList<Location> getMoveLocs(int Moves, Location loc){
		ArrayList<Location> locs = new ArrayList();
		locs.add(loc);		
		
		for(int counter = 0; counter < 360; counter += 90){
			boolean validmove = true;
			if(getGrid().isValid(loc.getAdjacentLocation(counter)) == false){
				validmove = false;
			}
			if(validmove){
				if(Moves - moveCost(getGrid().getTerrain(loc.getAdjacentLocation(counter))) >= 0){
					
					if(getGrid().isValid(loc.getAdjacentLocation(counter)) == false){
						validmove  = false;
					}else if(getGrid().get(loc.getAdjacentLocation(counter)) != (null)){
						if (((Unit) getGrid().get(loc.getAdjacentLocation(counter))).comparePlayer(999))
							validmove = false;
					}
					
						if(validmove){
							locs.add(loc.getAdjacentLocation(counter));
							ArrayList<Location> newlocs = getMoveLocs(Moves - moveCost(getGrid().getTerrain(loc.getAdjacentLocation(counter))), loc.getAdjacentLocation(counter));
							for(Location newloc: newlocs){
								for(int count = 0; count < locs.size(); count++){
									if(locs.get(count).equals(newloc)){
										locs.remove(count);
									}
								}
							}
							locs.addAll(newlocs);
						}
	
				}
			}
		}
	
		return locs;
		
	}
	
}
